﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using DrivingCRM.Controller;

namespace DrivingCRM.Views.Private.CMS
{
    public partial class AddArticles : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// Méthode déclenchée au clic sur le bouton d'insertion d'un article
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Insert_button_Click(object sender, EventArgs e)
        {
            string ret = EntityManager.AddArticle(this.TB_Title.Text, this.RE_Content.Content, this.DDL_Category.SelectedValue);
            if (ret == "No error")
            {
                this.L_ErrorMessage.Text = "Le nouvel article a correctement été ajouté";
                Response.Redirect("~/Views/Default.aspx");
            }
            else
                this.L_ErrorMessage.Text = "Une erreur est survenue lors de l'ajout d'un article, veuillez saisir les champs requis.";
        }


    }
}